
             
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @File name:  TProductCommentDao.java 
 * @Create on:  2012-10-27 19:50:313
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
package com.boho.ecp.member.dao;

            
import java.sql.Connection;
import java.util.List;

import cn.boho.framework.po.CQuery;
import cn.boho.framework.po.CQueryFactoryTool;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.DAO;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.Pager;
            
/**
 * 【会员商品评论信息:T_PRODUCT_COMMENT】的Dao操作类
 * 
 */
public class TProductCommentDao extends DAO {
	/**
	* 分页查询所有【会员商品评论信息:T_PRODUCT_COMMENT】信息
	* @param con
	* @param pager
	* @return
	* @throws Exception
	* @date 2012-10-27
	* @author 陈伟
	*
	*/
	public static ComboPager queryTProductCommentPagerByProductId(Connection con,Pager pager, Integer productId)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PRODUCT_COMMENT where IS_PASS = 1 and IS_VALID = 1 and PRODUCT_ID = ? order by COMMENT_DATE desc");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setInt(1, productId);
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_PRODUCT_COMMENT", pager,con);
	}
	
	/**
	 * 根据会员ID查询评论内容
	 * @param con
	 * @param pager
	 * @param memberId
	 * @return
	 * @throws Exception
	 */
	public static ComboPager queryTProductCommentPagerByMemberId(Connection con,Pager pager, Integer memberId)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PRODUCT_COMMENT where IS_VALID = 1 and MEMBER_ID = ? order by COMMENT_DATE desc");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setInt(1, memberId);
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_PRODUCT_COMMENT", pager,con);
	}
	
	/**
	 * 根据商品ID列表查询评论内容
	 * @param con
	 * @param memberId
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public static List queryTProductCommentListByIds(Connection con, Integer memberId, String ids) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PRODUCT_COMMENT where IS_VALID = 1 and MEMBER_ID = ? and PRODUCT_ID in (" + ids + ") order by COMMENT_DATE desc");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setInt(1, memberId);
		query.setCommand(sql.toString());
		return query.getDynaBeanMapList("T_PRODUCT_COMMENT", con);
	}
	
	/**
	* 根据主键【会员商品评论编号:PRODUCT_COMMENT_ID|】获得信息
	* @param con
	* @param productCommentId 会员商品评论编号
	* @return
	* @throws Exception
	* @date 2012-10-27
	* @author 陈伟
	*
	*/
	public static DynaBeanMap getTProductCommentByPk(Connection con,java.lang.Integer productCommentId)throws Exception{
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PRODUCT_COMMENT where IS_VALID = 1 and PRODUCT_COMMENT_ID=? ");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1,productCommentId);
		dynaBeanMap = query.getDynaBeanMap("T_PRODUCT_COMMENT", con);
		return dynaBeanMap;
	}
	
	public static List getTProductCommentCount(Connection con,java.lang.Integer productId)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select SCORE, count(*) NUM from T_PRODUCT_COMMENT where IS_PASS = 1 and IS_VALID = 1 and PRODUCT_ID=? group by SCORE");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1,productId);
		return query.getDynaBeanMapList("T_PRODUCT_COMMENT", con);
		
	}
}
